// See xrx_prod30_bidfluency.pm for documentation
// Version 1.6 19Dec2008 jimca https://ftr1.external.xerox.com 

var _mt_scriptVersion = "1.6";
	
var _mtA = 22695477, _mtC = 1013904223, _mtM = Math.pow(2,32), _mtfc = 1, _mt2 = 2000000000; 
_mtrnd.seed=1; 
_mtrnd.today=new Date(); 
_mtrnd.sd = _mtrnd.today.getTime(); 

if (typeof(_mt_newHitGuid) == "undefined") 
    var _mt_newHitGuid = _mt_newGuid();
if (typeof(_mt_sessionID) == "undefined" )
    var _mt_sessionID = _mt_newGuid();
if (typeof(_mt_visitorID) == "undefined" )
    var _mt_visitorID = _mt_newGuid();
function _mtrnd() { _mtrnd.seed = (_mtrnd.seed*_mtA+_mtC) % _mtM;	return _mtrnd.seed/(_mtM*1.0); };
function _mtHS(s) {s = ""+s;var h = 1;for (i=0;i<s.length;i++){ var x = s.charCodeAt(i); h = (h+x*x*h+x) % _mt2; }; return h;};
function _mtins() { _mtrnd.seed  = (_mtHS(document.URL)+_mtHS(document.referrer)+_mtHS(navigator.userAgent)) % _mt2; };
function _mtgetP(N,p) { N = N % 31536000000; N = N.toString(0x10); if (p<N.length) return N.substring(p,p+1); else return "0"; };
function _mt_newGuid()
{		
        var g = ""; 
        for(var i = 0; i < 9; i++) g += _mtgetP(_mtrnd.sd,i)+(i == 7 || i == 11 || i == 15 || i == 19 ? "-" : "");
        if (_mtfc==1) { _mtins(); _mtfc =0;}; 
        for(var i = 9; i < 25; i++) g += Math.round(_mtrnd()*0xf).toString(0x10)+(i == 7 || i == 11 || i == 15 || i == 19 ? "-" : "");
		for(var i = 25; i < 32; i++) g += Math.round(Math.random()*0xf).toString(0x10)+(i == 7 || i == 11 || i == 15 || i == 19 ? "-" : "");
		return g;
};

/*	query string parsing */	
function _mt_parseParameter(QueryString, Key)
{	
	var substringQuery;
	var nLength = Key.length + 1;
	if (QueryString.toLowerCase ().lastIndexOf (Key + "=") >= 0)
	{
		substringQuery = QueryString.substring (QueryString.toLowerCase ().lastIndexOf (Key + "=") + nLength);
		if (substringQuery.indexOf ("&") >= 0)
			return escape (substringQuery.substring (0, substringQuery.toLowerCase ().indexOf ("&")));
		else
			return escape (substringQuery);
	}
	return "";
}

if (typeof (_mt_isTrack) == "undefined")
	_mt_isTrack = "";
/*	Don't save repeated hit - but save new Event	!!!	*/
var _mt_saveHit = 1;
var _mt_isTrackPart = "";
var _mt_separatorPosition  = _mt_isTrack.indexOf (";" + mmtUserID + ";");
if (_mt_separatorPosition >= 0)
{	
	_mt_saveHit = 0;
	_mt_isTrackPart = _mt_isTrack.substring(_mt_separatorPosition);
	
	_mt_separatorPosition  = _mt_isTrackPart.indexOf(";", 1)
	if ( _mt_separatorPosition > 0 )
	{
		_mt_isTrackPart = _mt_isTrackPart.substring(_mt_separatorPosition + 1);
		var _mt_subs = _mt_isTrackPart.split(";");
		if (_mt_subs.length > 0 )
			_mt_newHitGuid = _mt_subs[0];
	}
}
else
{
	if (_mt_isTrack.length > 0)
		_mt_newHitGuid = _mt_newGuid();

	_mt_isTrack = _mt_isTrack + ";" + mmtUserID + ";" + _mt_newHitGuid;
}
_mt_referrer = escape (document.referrer);
_mt_url = escape (document.location.href);

_mt_SH = screen.height;
_mt_SW = screen.width;
_mt_CD = screen.colorDepth;

_mt_dt = new Date ();
_mt_UserDate = escape (_mt_dt.getFullYear () + "-" + (_mt_dt.getMonth () + 1) + "-" + _mt_dt.getDate () + " " + _mt_dt.getHours () + ":" + _mt_dt.getMinutes () + ":" + _mt_dt.getSeconds ());
_mt_TimeOffset = escape (_mt_dt.getTimezoneOffset ());
_mt_rrnd = Math.random();

//_mt_trurl = document.location.protocol + "//tracker.roitesting.com";
_mt_trurl = "https://ftr1.external.xerox.com";
if (document.location.port != null && document.location.port.length > 0)
    _mt_trurl = _mt_trurl + ":" + document.location.port;
_mt_img = _mt_trurl + "/SiteTracker.aspx?r="+_mt_rrnd+"&uid=" + mmtUserID + "&ref=" + _mt_referrer + "&SH=" + _mt_SH + "&SW=" + _mt_SW + "&CD=" + _mt_CD + "&url=" + _mt_url + "&udt=" + _mt_UserDate + "&toffset=" + _mt_TimeOffset;

if (typeof (mmtLOB) != "undefined")
    _mt_img = _mt_img + "&xlob=" + mmtLOB;
if (typeof (mmtCountry) != "undefined")
    _mt_img = _mt_img + "&xcntry=" + mmtCountry;

_mt_qs = document.location.href;
if (typeof (_mt_pc) != "undefined")
{
	_mt_ppcseid = _mt_pc;
	_mt_ppcsekw = _mt_pk;
	_mt_ppcseprice = "0";
	_mt_img = _mt_img + "&ppcseid=" + _mt_ppcseid + "&ppcsekw=" + _mt_ppcsekw + "&ppcseprice=" + _mt_ppcseprice;
}
/*	Script Version */
_mt_img = _mt_img + "&version=" + escape(_mt_scriptVersion);
/*	PPCSE Parameters */	
if (_mt_qs.toLowerCase ().indexOf ("ppcseid=") > 0)
{
	_mt_ppcseid		= escape(_mt_parseParameter(_mt_qs, "ppcseid"));
	_mt_ppcsekw		= escape(_mt_parseParameter(_mt_qs, "ppcsekeyword"));
	mmtctg		= escape(_mt_parseParameter(_mt_qs, "mmtctg"));
	mmtcmp		= escape(_mt_parseParameter(_mt_qs, "mmtcmp"));
	mmtmt		= escape(_mt_parseParameter(_mt_qs, "mmtmt"));
	mmtmtname   = escape(_mt_parseParameter(_mt_qs, "mmtmtname"));
	mmtadid		= escape(_mt_parseParameter(_mt_qs, "mmtadid"));
	mmtgglcnt	= escape(_mt_parseParameter(_mt_qs, "mmtgglcnt"));
	_mt_img =	_mt_img + "&ppcseid=" + _mt_ppcseid + "&ppcsekw=" + _mt_ppcsekw + "&mmtctg=" + mmtctg + "&mmtcmp=" + mmtcmp + "&mmtmt=" + mmtmt + "&mmtmtname=" + mmtmtname + "&mmtadid=" + mmtadid + "&mmtgglcnt=" + mmtgglcnt;
}
/*	Hit Guid */	
_mt_img = _mt_img + "&hitGuid=" + _mt_newHitGuid;
/*	bugfix for cookieless sessions  */
_mt_img = _mt_img + "&sessionId=" + _mt_sessionID + "&visitorID=" + _mt_visitorID;
/*	Event parameters */
_mt_img = _mt_img + "&save=" + (_mt_saveHit == 1 ? "true" : "false" );
if (typeof(mmtEventName) != "undefined" &&  typeof(mmtEventAmount) != "undefined" &&  typeof(mmtEventProfit) != "undefined" &&  typeof(mmtEventOrderNumber) != "undefined" &&  typeof(mmtEventProductName) != "undefined" &&  typeof(mmtEventCurrency) != "undefined" &&  typeof(mmtEventParametersString) != "undefined")
{
	_mt_img = _mt_img + "&etype=" + escape(mmtEventName) + "&ROICost=" + escape(mmtEventAmount) + "&profit=" + escape(mmtEventProfit) + "&order=" + escape(mmtEventOrderNumber) + "&product=" + escape(mmtEventProductName) + "&cur=" + escape(mmtEventCurrency) + "&params=" + escape(mmtEventParametersString);
}

var _mt_image = new Image(); 
_mt_image.src = _mt_img;
